﻿using System;
using System.Collections.Generic;
using System.Text;
using UtilZ.Dotnet.Ex.Base;

namespace UtilZ.Dotnet.Ex.Communication.Net.Telnet.KeyCommands
{
    internal class EscCommand : TelnetKeyCommandAbs
    {
        /**********************************************
         *          windows  linux      mac
         * code     27       27         49         
         **********************************************/

        public EscCommand()
              : base()
        {

        }

        protected override bool PrimitveProcess(ListenTelnetClient telnetClient, byte[] data, int revicedDataLength)
        {
            if (revicedDataLength != 1)
            {
                return false;
            }

            if ((telnetClient.Platform == OSPlatformID.Win || telnetClient.Platform == OSPlatformID.Linux_Unix) && data[0] == 27 ||
                telnetClient.Platform == OSPlatformID.MacOS && data[0] == 49)
            {
                base.SendEcho(telnetClient, data, revicedDataLength);
                return true;
            }

            return false;
        }
    }
}
